Skip to content

Review follow-ups: lead alert backlog, wrong numbers, listening lists and webhook - #5

Merged
operatoruplift merged 8 commits into
mainfrom
claude/review-followups
Nov 4, 2026
Merged

operatoruplift merged 8 commits into
mainfrom
claude/review-followups

Conversation

@operatoruplift

Copy link
Copy Markdown
Owner

The rest of the review of #2, one commit each. #4 fixed the first two (opt-outs and one-line quiz answers).

What's in it

  • Lead alerts never skip leads past one look's 500 (f38b686). Twenty lists records by id, not by time, so when more than 500 leads came in between two looks, a look read 500 in id order and marked seen up to the newest of those, past older leads it never read. With no qualified lead among the 500, none of them was pushed. A look now reads every lead up to a time: when more came in than it reads, the window closes at the median time of what it read until it fits, and the next look carries on from there.
  • A wrong or bad number holds for 90 days, and only for that number (6d3e0ae). The phone stopped counting as a way to reach someone forever after one wrong-number call, even once their number was corrected in Twenty. It now stays off for 90 days (the window "not interested" already uses) and only while their phone is the number that was dialed, compared by its last ten digits. reachableOn takes the decision's clock.
  • One saved list per listening watch (76a0ee7). Save as a list named the file after the watch's name alone, so two watches with the same name shared one list. It is now prospects-listen-<name>-<id>.csv; every watch together stays prospects-listen-all.csv.
  • The listening webhook stops reading at its size limit (8f68135). A delivery sent in chunks has no Content-Length, so the whole body was read before the 2 MB check. It is now read a chunk at a time and cancelled as soon as it passes the limit, in bytes.
  • A delivery's matches a hundred to a statement (cefbb19). Each match was its own awaited INSERT: 500 round trips for a 500-match digest, inside one webhook request on Vercel and Turso. Now one multi-row INSERT per hundred; ON CONFLICT still keeps each key once, a repeat within one delivery included.
  • claimRun and metaValue each keep their own comment (744bf60).
  • The default calling hours are copied in one place (dab0abf). The shallow copy that shared DEFAULT_CALL_HOURS.days never left parseConfig (a calls: that isn't a mapping fails the whole config), so this changes no behaviour; both branches now copy through one helper.

docs/decision-engine.md and the CHANGELOG say what changed for wrong numbers, saved lists and lead alerts.

How it was checked

  • bun run check: 397 tests pass (5 new), typecheck and the message lint clean.
  • Each new test fails on main without its fix: a 1,200-lead backlog whose ids sort in another order than their times (each lead found exactly once across looks), a wrong number that is old or no longer theirs, two same-named watches saved as lists, a chunked delivery over the limit (refused after about 2 MB of a 6.5 MB body), and 250 matches kept in three statements.

Generated by Claude Code

Twenty lists records by id, not by time. When more than 500 leads came in
between two looks, a look read 500 of them in id order and marked seen up
to the newest of those, past older leads it had never read. With no
qualified lead among the 500, nothing was pushed for any of them.

A look now reads every lead up to a time: when more came in than it
reads, it closes the window at the median time of what it read, again
until the window fits, and the next look carries on from there. Seen
never passes a lead that wasn't read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TZhsuVXF5k9RXQpSdqYkdV
reachableOn dropped the phone whenever the dialer's latest call was a
wrong or bad number, with no end and no look at which number was dialed:
a prospect whose number was corrected in Twenty, or whose wrong number was
logged two years ago, was never reachable by phone again.

The phone now stays off only for 90 days (the window "not interested"
already uses) and only while the prospect's phone is the number that was
dialed, compared by its last ten digits. reachableOn takes the decision's
clock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TZhsuVXF5k9RXQpSdqYkdV
Save as a list named the file after the watch's name alone, so two
watches with the same name wrote into one prospects-listen-<name>.csv and
a campaign on it reached both watches' matches.

The file is now named for the watch and its id,
prospects-listen-<name>-<id>.csv; every watch together stays
prospects-listen-all.csv.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TZhsuVXF5k9RXQpSdqYkdV
A delivery sent in chunks has no Content-Length, so the webhook read the
whole body with request.text() before it compared it with the 2 MB limit:
a large or endless body was held in memory first and refused only after.

The body is now read a chunk at a time and the request is cancelled as
soon as it passes the limit, in bytes rather than characters.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TZhsuVXF5k9RXQpSdqYkdV
ListenStore.receive wrote each match with its own awaited INSERT, so a
500-match digest made 500 round trips to the database inside one webhook
request: on Vercel with Turso, enough to risk the function's time limit.

Matches now go in one multi-row INSERT per hundred (seven values each, far
under SQLite's limit), and ON CONFLICT still keeps each key once, a match
repeated within one delivery included. The count of matches added is
unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TZhsuVXF5k9RXQpSdqYkdV
claimRun was added between metaValue's doc comment and metaValue, so
claimRun carried two comments, the first describing metaValue, and
metaValue had none. Each now sits above its own function.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TZhsuVXF5k9RXQpSdqYkdV
parseCalls copied the default days in one branch and returned a shallow
copy that shared DEFAULT_CALL_HOURS.days in the other. That copy never
left parseConfig (a calls: section that isn't a mapping fails the whole
config), but both branches now go through one helper that copies the
days, and a test checks a parsed config has its own.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TZhsuVXF5k9RXQpSdqYkdV
@vercel

vercel Bot commented Nov 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
coldthecompany Ready Ready Preview Nov 4, 2026 9:29am UTC

Request Review

@operatoruplift
operatoruplift merged commit 6ff214c into main Nov 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants